<?php 

/*

print_r(getenv('REMOTE_ADDR')) ;
echo '<br />';

var_dump(getenv('HTTP_X_FORWARDED_FOR'));
echo '<br />';


function getRealIp(){
	static $realip = null;

	if ($realip !==null) {
		return $realip;
	}
    //三种方式
	if (getenv('REMOTE_ADDR')) {                  //当前页面客户端ip
		$realip = getenv('REMOTE_ADDR');         
	}elseif (getenv('HTTP_CLIENT_IP')) {          //iis服务器上 ip
		$realip = getenv('HTTP_CLIENT_IP');      
	}elseif (getenv('HTTP_X_FORWARDED_FOR')) {    //代理上网 ip
		$realip = getenv('HTTP_X_FORWARDED_FOR');
	}
	//返回真实IP
	//把标准IPv4转成数字(有可能是负数)   在把数字转成unsigned类型返回存入数据库
	return sprintf('%u',ip2long($realip)); 
}

echo getRealIp();


//print_r(phpinfo());

//print_r($_FILES);

//print_r($_FILES['org_img']['error']); //0

print_r($_POST);
echo '<br />';

print_r($_SERVER[REQUEST_URI]);



function randM(){
	$str = 'qazwsxedcrfvtgbyhnujmikolp~!@#$%^&*()_+QAZWSXEDCRFVTGBYHNUJMIKOLP23456789';
	return substr(str_shuffle($str), 0,6);
}


echo randM();


function md5Password($password='123456',$salt='gPINLG'){
	return md5($password.$salt);
}

echo md5Password();


print_r($_SERVER['REQUEST_URI']);

header("location:$_SERVER[REQUEST_URI]")





function HisTory(){
	$uri = $_SERVER['REQUEST_URI'];
	if (!isset($_COOKIE['history'])) {  //第一次浏览
	
	$his[] = $uri;                   //把浏览URI放$his
    }else {
    $his = explode('|', $_COOKIE['history']);  //分割字符串为数组
    $his[] = $uri;
   
    $his = array_unique($his);       //去掉数组中重复值   
    array_unshift($his, $uri);       //新的排前面

    if (count($his)>5) {             //大于5 去掉尾行
   	array_pop($his);                 
    }
   
}
 setcookie('history',implode('|', $his));   //创建cookie
 return $his;
}


//$uri = $_SERVER['REQUEST_URI'];
//$id = isset($_GET['id'])?$_GET['id']:0;

$a = HisTory();
var_dump($a);
print_r($_COOKIE);




<ul>
	<li>历史浏览</li>
	<?php foreach ($a as $v) { ?>
	<li><?php echo $v;?></li>	
	<?php }; ?>
</ul>
*/

$str = (0123456789);
echo preg_replace("/^[123456789]$/", 0, $str);

?>






